<template>
    <div>
        <el-card class="box-card" style="margin-top:100px">
            <div slot="header" class="clearfix">
                <el-button style="float: right; padding: 3px 0" type="text" size="medium" @click="list">更多</el-button>
                <span>
                    <h1>职位推荐</h1>
                </span>
            </div>
        </el-card>
        <el-row>
            <el-col :span="8" v-for="jobRecruitment in jobRecruitments" :key="jobRecruitment.job_recruitment_id">
                <div @click="jobRecruitmentDetail(jobRecruitment.job_recruitment_id)">
                    <el-card :body-style="{ padding: '20px' }">
                        <el-card style="background-color:rgb(197, 197, 197)" size="medium">职位名称:{{ jobRecruitment.job_title
                        }}</el-card>
                        <el-card style="width: 290px" size="medium" class="el-icon-menu">职位分类:{{
                            jobRecruitment.job_classification }}</el-card>
                        <el-card style="width: 290px" size="medium" class="el-icon-user-solid">企业名称:{{
                            jobRecruitment.enterprise_name
                        }}</el-card>
                        <el-card size="medium">薪资:{{ jobRecruitment.salary }}</el-card>
                        <el-tag size="medium" class="el-icon-view">{{ jobRecruitment.hits }}</el-tag>
                        <el-tag size="medium" class="el-icon-date">发布时间:{{ format(jobRecruitment.create_time).format
                        }}</el-tag><br>
                        <el-button type="primary" size="medium"
                            @click="detail(jobRecruitment.job_recruitment_id)">查看详情</el-button>
                    </el-card>
                </div>
            </el-col>
        </el-row>
    </div>
</template>
<script>
import axios from 'axios';
import dateTime from '@/utils/date_time';
export default {
    data() {
        return {
            jobRecruitments: []
        }
    },
    methods: {
        detail(id) {
            this.$router.push({ name: 'job_recruitment_detail', params: { job_recruitment_id: id } }, () => { }, () => { });
        },
        format(create_time) {
            return dateTime.dateTime(create_time)
        },
        list() {
            this.$router.push({ name: 'job_recruitment_list' }, () => { }, () => { });
        }
    },
    created: function () {
        let that = this;
        axios.get('http://127.0.0.1:5000/api/job_recruitment/get_list', {
            params: {
                page: 1,
                size: 6
            }
        })
            .then(function (response) {
                console.log(response.data.result);
                that.jobRecruitments = response.data.result.list;
            })
            .catch(function (error) {
                console.log(error);
            })
            .then(function () {
                // 总是会执行
            })
    },
}
</script>
<style scoped>
.text {
    font-size: 14px;
}

.item {
    padding: 18px 0;
}

.box-card {
    margin-left: 200px;
    width: 1500px;
    height: 100px;
}
</style>